$(function () {
    var productId = getUrlParams('myid');
    // console.log(productId);
    $.ajax({
        url: 'http://127.0.0.1:3000/api/getproduct',
        data: {productid: productId},
        dataType: 'json',
        success: function (data) {
            console.log(data);
            var displayName = data.result[0].productName.substring(0, 3);
            var productNameLiTag = '<li class="active">' + displayName + '</li>';
            // $('.breadcrumb').append(productNameLiTag);



            var categoryId = data.result[0].categoryId;
            $.ajax({
                url: 'http://127.0.0.1:3000/api/getcategorybyid',
                data: {categoryid: categoryId},
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    var categoryNameLiTag = '<li><a href="category_product_list.html?categoryid='+categoryId+'">'+data.result[0].category+'</a></li>';
                    $('.breadcrumb').append(categoryNameLiTag);
                    $('.breadcrumb').append(productNameLiTag);

                }
            })

            var html = template('product-img', data);
            $('#product>.product-img').html(html);

            var html=template('bjShop',data);
            $('#product>.product-buy').html(html);
            //评价
            $.ajax({
                url:'http://127.0.0.1:3000/api/getproductcom',
                data:{productid:productId},
                dataType:'json',
                success:function (data) {
                    console.log(data);

                    var tmpData = {
                        result:[data.result[0],data.result[1]]
                    };
                    

                    var html=template('appraise',tmpData);

                    $('#product>.product-appraise').html(html);


                    $(".product-b > p").click(function(){
                        console.log("click");
                        var html=template('appraise',data);
                        $('#product>.product-appraise').html(html);

                    });
                }
            })






        }
    });
})